package com.example.mobifin_busticket.models;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class SeatDetailsModel {
	boolean availableSeat, ladiesSeat;
	private String name, serviceTaxAbsolute, serviceTaxPercentage, baseFare;
	private int column, length, width, zIndex, row,Fare;

	public boolean isAvailableSeat() {
		return availableSeat;
	}

	public void setAvailableSeat(boolean availableSeat) {
		this.availableSeat = availableSeat;
	}

	public String getBaseFare() {
		return baseFare;
	}

	public void setBaseFare(String baseFare) {
		this.baseFare = baseFare;
	}

	public boolean isLadiesSeat() {
		return ladiesSeat;
	}

	public void setLadiesSeat(boolean ladiesSeat) {
		this.ladiesSeat = ladiesSeat;
	}

	public String getServiceTaxAbsolute() {
		return serviceTaxAbsolute;
	}

	public void setServiceTaxAbsolute(String serviceTaxAbsolute) {
		this.serviceTaxAbsolute = serviceTaxAbsolute;
	}

	public String getServiceTaxPercentage() {
		return serviceTaxPercentage;
	}

	public void setServiceTaxPercentage(String serviceTaxPercentage) {
		this.serviceTaxPercentage = serviceTaxPercentage;
	}

	public int getColumn() {
		return column;
	}

	public void setColumn(int column) {
		this.column = column;
	}

	public int getLength() {
		return length;
	}

	public void setLength(int length) {
		this.length = length;
	}

	public int getWidth() {
		return width;
	}

	public void setWidth(int width) {
		this.width = width;
	}

	public int getzIndex() {
		return zIndex;
	}

	public void setzIndex(int zIndex) {
		this.zIndex = zIndex;
	}

	public int getRow() {
		return row;
	}

	public void setRow(int row) {
		this.row = row;
	}

	public Integer getFare() {
		return Fare;
	}

	public void setFare(Integer fare) {
		Fare = fare;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public static ArrayList<SeatDetailsModel> parseTripsDetails(String response) {
		ArrayList<SeatDetailsModel> SeatDetailsList = new ArrayList<SeatDetailsModel>();
		JSONObject json;
		try {
			json = new JSONObject(response);
			JSONArray SeatArray = json.getJSONArray("seats");
			for (int i = 0; i < SeatArray.length(); i++) {
				JSONObject seatObj = SeatArray.getJSONObject(i);
				SeatDetailsModel seatModel = new SeatDetailsModel();
				seatModel.setAvailableSeat(seatObj.getBoolean("available"));
				seatModel.setBaseFare(seatObj.getString("baseFare"));
				seatModel.setColumn(seatObj.getInt("column"));
				seatModel.setFare(seatObj.getInt("fare"));
				seatModel.setLadiesSeat(seatObj.getBoolean("ladiesSeat"));
				seatModel.setLength(seatObj.getInt("length"));
				seatModel.setName(seatObj.getString("name"));
				seatModel.setRow(seatObj.getInt("row"));
				seatModel.setServiceTaxAbsolute(seatObj
						.getString("serviceTaxAbsolute"));
				seatModel.setServiceTaxPercentage(seatObj
						.getString("serviceTaxPercentage"));
				seatModel.setWidth(seatObj.getInt("width"));
				seatModel.setzIndex(seatObj.getInt("zIndex"));
				SeatDetailsList.add(seatModel);
			}
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return SeatDetailsList;
	}

}
